package com.ymatou.iapi.godmch.testcase;


import org.json.JSONArray;
import org.json.JSONObject;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;
import org.junit.experimental.categories.Category;

import com.google.gson.Gson;
import com.ymatou.iapi.godmch.parameter.MchInfoVo;
import com.ymatou.iapi.godmch.parameter.getAllChainShopIdListBean;
import com.ymatou.iapi.godmch.service.getAllChainShopIdListCall;
import com.ymt.core.tool.Logger;
import com.ymt.utils.annotation.*;
import com.ymt.utils.tag.*;
import com.ymttest.database.model.mch_info;
import com.ymttest.database.sqlwapper.godmch.DefGodMchWapper;
import com.ymttest.utils.EnvSetup;
/**
*获取所有关联的连锁店idid
*FreeMaker Template自动生成代码
*/
@TestSuite
public class Ts_getAllChainShopIdList{
	private static getAllChainShopIdListBean bean;
	private static getAllChainShopIdListCall call;
	DefGodMchWapper DefGodMchWapper=new DefGodMchWapper();
	Integer masterChainShopId_wechatDirectPayMode=Integer.parseInt(EnvSetup.getData("masterChainShopId_wechatDirectPayMode"));
	
	@BeforeClass
	public static void setUp() {
		Logger.createResultFile("获取所有关联的连锁店idid");
	}

	@Before
	public void caseUp() {
		bean=new getAllChainShopIdListBean();
		call=new getAllChainShopIdListCall();
	}

	@AfterClass
	public static void tearDown() {
		Logger.generateResult(call.getOpurl());
	}

	@After
	public void caseDown() {
		Logger.end();
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getAllChainShopIdList_001() {
		Logger.start(true,"获取所有关联的连锁店id");
		try {
			
			bean.setMchId(masterChainShopId_wechatDirectPayMode);
			call.setData(bean);
			call.callService();	
					
			JSONArray jArray=new JSONObject(call.getReturnData()).getJSONObject("result").getJSONArray("chainShopList");
		    
			Logger.verifyEquals("200", call.getString("status"), "验证status");
			Logger.verifyEquals(11, new JSONObject(jArray.get(0).toString()).getInt("shopId"), "验证shopId");
			Logger.verifyEquals(bean.getMchId(), new JSONObject(jArray.get(1).toString()).getInt("shopId"), "验证MchId");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
	@Test
	@Category({P1.class})
	@TestCase
	public void Tc_getAllChainShopIdList_002() {
		Logger.start(true,"获取所有关联的连锁店id-mch为空");
		try {

			call.setData(bean);
			call.callService();			
			
			Logger.verifyEquals("4001", call.getString("status"), "验证status");
			
		} catch (Exception e) {
			Logger.fail(e);
		}
	}
}